import time, datetime

# wrapper for class method
class Callable:
    def __init__(self, anycallable):
        self.__call__ = anycallable

class Timestamp:
    def __init__(self):
        pass

    def utcepoch():
        return int(time.mktime(datetime.datetime.utcnow().timetuple()))

    def utcepoch_from(dt):
        if not isinstance(dt, datetime.datetime):
            raise TypeError, "%s() argument must be a datetime, not '%s'" % (utc_epoch.func_name, type(dt))

        t = datetime.datetime.utcnow()
        return int(time.mktime(t.timetuple()))

    def utcdatetime():
        return datetime.datetime.utcnow()

    def utcdatetime_from(epoch):
        return datetime.datetime.utcfromtimestamp(epoch)

    # class methods
    utcepoch = Callable(utcepoch)
    utcepoch_from = Callable(utcepoch_from)
    utcdatetime = Callable(utcdatetime)
    utcdatetime_from = Callable(utcdatetime_from)

if __name__ == '__main__':
    print Timestamp.utcepoch()
    print Timestamp.utcepoch_from(datetime.datetime.utcnow()) 
    print Timestamp.utcdatetime()
    print Timestamp.utcdatetime_from(Timestamp.utcepoch())
